Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: QuickTime

Previous | Overview | Contents | Next |

Editing Tracks

The Movie Toolbox provides a number of functions that allow your application to perform editing operations on tracks. These functions work with track segments--pieces of a track that are defined by a starting time and duration--and therefore give you a great deal of control over the editing process. These functions are similar to the low-level editing functions for movies that were described earlier in this chapter. However, these functions may copy movie data, if required by the operation.

When you edit a track you may change the duration of the movie that contains that track.

The CopyTrackSettings function lets you copy certain important settings from one track to another.

You can use the InsertTrackSegment function to copy a segment from one track to another, by reference or by moving data, or to copy a segment within a track. The InsertTrackEmptySegment function allows you to insert an empty segment into a track.

You can use the InsertMediaIntoTrack function to insert a media into a track.

Your application can delete a segment from a track by calling the DeleteTrackSegment function.

You can change a segment's duration by calling the ScaleTrackSegment function. This function stretches or shrinks the segment to accommodate a specified duration.

You can use the GetTrackEditRate function to determine the rate of the track edit of a specified track at an indicated time.

InsertTrackSegment

The InsertTrackSegment function copies part of one track to another. You specify the starting time and duration of the source segment and the time in the destination track at which to place the information.

If you have opened the destination media for writing by calling BeginMediaEdits , the media data in the segment will be copied. If the destination media is not open for writing, the segment will be copied by reference.

pascal OSErr InsertTrackSegment (Track srcTrack, Track dstTrack,
                                         TimeValue srcIn,
                                         TimeValue srcDuration,
                                         TimeValue dstIn);
srcTrack
Specifies the source track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

dstTrack
Specifies the destination track for this operation. The InsertTrackSegment function places a copy of the segment, which is obtained from the source track, into this destination track. The media for the destination track must be opened for writing by calling BeginMediaEdits in order for the data to be copied. If the media is not opened for writing, the segment will be copied by reference.

srcIn
Specifies the start of the segment in the source track. The srcDuration parameter specifies the segment's duration. This time value must be expressed in the time scale of the movie that contains the source track.

srcDuration
Specifies the duration of the segment in the source track. This time value must be expressed in the time scale of the movie that contains the source track.

dstIn
Contains a time value specifying where the segment is to be inserted. This time value must be expressed in the time scale of the movie that contains the destination track.

DESCRIPTION

The InsertTrackSegment function does not change the source track. The duration of the destination track is extended to accommodate the inserted segment. This may also change the duration of the movie that contains the destination track.

You can use this function to copy data within a single track. If you are copying data between tracks, make sure that the two tracks are of the same type. For example, you cannot copy a segment from a sound track into a video track.

Your application must call the BeginMediaEdits function before calling InsertTrackSegment in order to copy data samples into the destination media. Otherwise, the segment will be copied by reference. At the end of the editing session, your application must call the EndMediaEdits function if it has called BeginMediaEdits . See "Adding Samples to Media Structures," for more information about these functions.

If you copy a segment without calling BeginMediaEdits on the destination track's media, the data can be copied later by flattening the movie.

If you have assigned a progress function to the movie that contains the destination track, the Movie Toolbox calls that progress function during long copy operations.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

mediaTypesDontMatch

-2018

These media structures don't match

progressProcAborted

-2019

Your progress function returned an error

File Manager errors

InsertEmptyTrackSegment

The InsertEmptyTrackSegment function adds an empty segment to a track. You specify the starting time and duration of the empty segment to be added. These times must be expressed in the movie's time scale. This function then inserts the appropriate amount of empty time into the track. The exact meaning of the term empty time depends upon the type of track. For example, empty time in a sound track is silent.

pascal OSErr InsertEmptyTrackSegment (Track dstTrack,
                                         TimeValue dstIn,
                                         TimeValue dstDuration);
dstTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

dstIn
Contains a time value specifying where the segment is to be inserted. This time value must be expressed in the time scale of the movie that contains the destination track.

dstDuration
Contains a time value that specifies the duration of the segment to be added. This time value must be expressed in the time scale of the movie that contains the destination track.

DESCRIPTION

Note that you cannot add empty space to the end of a movie or to the end of a track. If you try to add an empty segment beyond the end of a track, this function does not add the empty segment and returns a result code of invalidTime .

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

invalidDuration

-2014

This duration value is invalid

invalidTime

-2015

This time value is invalid

Memory Manager errors

InsertMediaIntoTrack

The InsertMediaIntoTrack function inserts a reference to a media segment into a track. You specify the segment in the media by providing a starting time and duration. You specify the point in the destination track by providing a time in the track.

pascal OSErr InsertMediaIntoTrack (Track theTrack,
                                         TimeValue trackStart,
                                         TimeValue mediaTime,
                                         TimeValue mediaDuration,
                                         Fixed mediaRate);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

trackStart
Contains a time value specifying where the segment is to be inserted. This time value must be expressed in the movie's time scale. If you set this parameter to -1, the media data is added to the end of the track.

mediaTime
Contains a time value specifying the starting point of the segment in the media. This time value must be expressed in the media's time scale.

mediaDuration
Contains a time value specifying the duration of the media's segment. This time value must be expressed in the media's time scale.

mediaRate
Specifies the media's rate. A value of 1.0 indicates the media's natural playback rate. This value should be a positive, nonzero rate.

DESCRIPTION

The InsertMediaIntoTrack function inserts the media segment into the track at the specified location. The Movie Toolbox determines the duration of the segment in the track based on the media rate and duration information you provide.

You use this function after you have added samples to a media using the functions described in "Adding Samples to Media Structures," . If you play the track before you call this function, the track does not contain the new media data.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

invalidDuration

-2014

This duration value is invalid

invalidTime

-2015

This time value is invalid

DeleteTrackSegment

The DeleteTrackSegment function removes a specified segment from a track. You identify the segment to remove by specifying its starting time and duration.

pascal OSErr DeleteTrackSegment (Track theTrack,
                                         TimeValue startTime, TimeValue duration);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

startTime
Contains a time value specifying the starting point of the segment to be deleted. This time value must be expressed in the time scale of the movie that contains the source track.

duration
Contains a time value that specifies the duration of the segment to be deleted. This time value must be expressed in the time scale of the movie that contains the source track.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

invalidDuration

-2014

This duration value is invalid

invalidTime

-2015

This time value is invalid

SEE ALSO

To dispose of a track, call the DisposeMovieTrack function, described on DisposeMovieTrack .

ScaleTrackSegment

The ScaleTrackSegment function changes the duration of a segment of a track. This may change the duration of the movie that contains the track. However, this function does not cause the Movie Toolbox to add data to or remove data from the movie.

pascal OSErr ScaleTrackSegment (Track theTrack,
                                         TimeValue startTime,
                                         TimeValue oldDuration,
                                         TimeValue newDuration);
theTrack
Specifies the track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

startTime
Specifies the start of the segment. The oldDuration parameter specifies the segment's duration. This time value must be expressed in the time scale of the movie that contains the track.

oldDuration
Specifies the duration of the segment. This time value must be expressed in the time scale of the movie that contains the track.

newDuration
Specifies the new duration of the segment. This time value must be expressed in the time scale of the movie that contains the track. The function alters the segment to accommodate the new duration.

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

invalidDuration

-2014

This duration value is invalid

invalidTime

-2015

This time value is invalid

Memory Manager errors

CopyTrackSettings

The CopyTrackSettings function copies many settings from one track to another, overwriting the destination settings.

pascal OSErr CopyTrackSettings (Track srcTrack, Track dstTrack);
srcTrack
Specifies the source track for this operation. Your application obtains this track identifier from such Movie Toolbox functions as NewMovieTrack and GetMovieTrack (described on NewMovieTrack and GetMovieTrack , respectively).

dstTrack
Specifies the destination track for this operation. The CopyTrackSettings function uses the settings from the source track, which you specify with the srcTrack parameter, to replace the current settings of this track.

DESCRIPTION

The CopyTrackSettings function copies the

This function does not copy any alternate group information pertaining to the track.

If you want to work with specific characteristics, you can use the Movie Toolbox functions that allow you to manipulate track settings individually. These functions are described in "Functions That Modify Movie Properties," which begins on Functions That Modify Movie Properties .

This function does not copy the track's contents. To work with track contents, you should use the segment-editing functions described in "Editing Tracks," .

ERROR CODES

invalidTrack

-2009

This track is corrupted or invalid

Memory Manager errors

GetTrackEditRate

The GetTrackEditRate function returns the rate of the track edit of a specified track at an indicated time.

pascal Fixed GetTrackEditRate (Track theTrack, TimeValue atTime);
theTrack
Specifies the track identifier for which the rate of a track edit (at the time given in the atTime parameter) is to be determined.

atTime
Indicates a time value at which the rate of a track edit (of a track identified in the parameter theTrack ) is to be determined.

DESCRIPTION

If an invalid time or track is passed, the returned value is 0.0. The track edit rate is typically 1.0, unless either the ScaleMovieSegment or ScaleTrackSegment function has been called. (For more on the ScaleMovieSegment and ScaleTrackSegment functions, see ScaleMovieSegment and ScaleTrackSegment , respectively.)

The GetTrackEditRate function is relevant if you are stepping through track edits directly in your application or if you are a client of the base media handler. (See Inside Macintosh: QuickTime Components for details on media handlers.)


© 1999 Apple Computer, Inc.

Previous | Overview | Contents | Next